added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / CSASPNETDragItemInListView / Default.aspx.cs
blob459083a8688e7842af15d8820f0e4d50d4f57ed5
1 /****************************** Module Header ******************************\
2 * Module Name: Default.aspx.cs
3 * Project: CSASPNETDragItemInListView
4 * Copyright (c) Microsoft Corporation
6 * The project illustrates how to drag and drop items in ListView using JQuery.
7 * In this page, bind two xml data files to ListView and use ItemTemplate to display
8 * them, cite JQuery javascript library to implements these functions in
9 * Default.aspx page.
11 * This source is subject to the Microsoft Public License.
12 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
13 * All other rights reserved.
15 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
16 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
17 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
18 '**************************************************************************/
21 using System;
22 using System.Web;
23 using System.Web.UI;
24 using System.Web.UI.WebControls;
25 using System.Xml;
26 using System.Data;
27 namespace CSASPNETDragItemInListView
29 public partial class Default : System.Web.UI.Page
31 protected void Page_Load(object sender, EventArgs e)
33 // Bind two xml data file to ListView control, actually you can change the "open" property to "0",
34 // In that way, it will not display in ListView control.
35 XmlDocument xmlDocument = new XmlDocument();
36 using (DataTable tabListView1 = new DataTable())
38 tabListView1.Columns.Add("value", Type.GetType("System.String"));
39 xmlDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "/XmlFile/ListView1.xml");
40 XmlNodeList xmlNodeList = xmlDocument.SelectNodes("root/data[@open='1']");
41 foreach (XmlNode xmlNode in xmlNodeList)
43 DataRow dr = tabListView1.NewRow();
44 dr["value"] = xmlNode.InnerText;
45 tabListView1.Rows.Add(dr);
47 ListView1.DataSource = tabListView1;
48 ListView1.DataBind();
51 XmlDocument xmlDocument2 = new XmlDocument();
52 using (DataTable tabListView2 = new DataTable())
54 tabListView2.Columns.Add("value2", Type.GetType("System.String"));
55 xmlDocument2.Load(AppDomain.CurrentDomain.BaseDirectory + "/XmlFile/ListView2.xml");
56 XmlNodeList xmlNodeList2 = xmlDocument2.SelectNodes("root/data[@open='1']");
57 foreach (XmlNode xmlNode in xmlNodeList2)
59 DataRow dr = tabListView2.NewRow();
60 dr["value2"] = xmlNode.InnerText;
61 tabListView2.Rows.Add(dr);
63 ListView2.DataSource = tabListView2;
64 ListView2.DataBind();